package org.example.intern.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.example.intern.entity.dto.res.TableListRes;
import org.example.intern.utils.Rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author: world
 * @date: 2022/4/18 17:00
 * @description:
 */

@Api(tags = "表格接口,示例用")
@RestController
@CrossOrigin(origins = "http://localhost:9528", allowCredentials= "true")
@RequestMapping("table")
public class TableController {

    @RequestMapping(value = "list",method = RequestMethod.GET)
    public Rest<Page<TableListRes>> list(){
        final ArrayList<TableListRes> tableListRes = new ArrayList<>();
        for(int x = 0 ; x < 10 ; x++ ) {
            tableListRes.add(new TableListRes());
        }
        final Page<TableListRes> page = new Page<>(1, 10);
        page.setRecords(tableListRes);
        page.setSize(10);
        page.setPages(0);
        page.setTotal(10);
        return Rest.success(page);
    }

}
